<template>
	<view class="conter">
		<header-box :title="title"></header-box>
		<view class="text-tab">
			<view class="flex-box1 box-width">
				<!-- <view class="" @tap="redactShow = true">
					创建日期
				</view> -->
				<view class="" @tap="search">
					重置<text class="cuIcon-triangledownfill"></text>
				</view>
				<view class="" @tap="redactShow2 = true">
					{{strackName ? strackName : '仓库'}}<text class="cuIcon-triangledownfill"></text>
				</view>
				<view class="" @tap="redactShow3 = true">
					{{supplierName ? supplierName : '供应商'}}<text class="cuIcon-triangledownfill"></text>
				</view>
			</view>
			<view class="box" v-for="(item, index) in textList" :key="index" @tap="goback(item.orderbm)">
				<view class="box-title">
					<view class="">
						{{item.supplier_name}}
					</view>
					<view class="" style="font-weight: 400;">
						{{item.store_name}}
					</view>
				</view>
				<view class="box-data">
					{{item.createtime}}
				</view>

				<view class="flex-box" style="height: 70rpx;">
					<view class="">
						备注：{{item.remark}}
					</view>
					<navigator url="#" class="" style="color: #7278EC;">
						查看商品>>
					</navigator>
				</view>
			</view>
		</view>


		<navigator url="/pages/putStock/addShop" class="add">
			<image src="../../static/index/add.png" mode=""></image>
		</navigator>




		<!-- 顶部弹层 -->
		<u-popup v-model="redactShow" mode="top" height="540" width="100%" border-radius="40">

			<!-- 公共头部 -->
			<header-box :title="title"></header-box>
			<view style="padding: 13rpx 23rpx;
				font-family: PingFang SC;
				background-color: #EBEBF0;
				color: #333333; width: 140rpx;
				font-size: 24rpx; margin: 30rpx;"
			 @click="redactShow = true">创建日期</view>
			<view class="text-fw" style="margin-left: 30rpx; margin-bottom: 30rpx;">
				搜索创建日期
			</view>
			<view class="box1">
				<view class="box-bgc" @tap="show = true">
					{{ statckTime ? statckTime :'开始时间'}}
				</view>
				-
				<view class="box-bgc" @tap="show1 = true">
					{{ endTime ? endTime :'结束日期'}}

				</view>
			</view>
			<view class="wh100 text-center padding-top">
				<view class="search-box bg-gradual-green" @tap="search">
					搜索
				</view>
			</view>
		</u-popup>



		<u-popup v-model="redactShow2" mode="top" width="100%" border-radius="40">

			<!-- 公共头部 -->
			<header-box :title="title"></header-box>
			<view style="padding: 13rpx 23rpx;
				font-family: PingFang SC;
				background-color: #EBEBF0;
				color: #333333; width: 140rpx;
				font-size: 24rpx; margin: 30rpx;
				text-align: center;">仓库</view>
			<view class="text-fw" style="margin-left: 30rpx; margin-bottom: 30rpx; ">
				仓库
			</view>
			<view class="cen">
				<view class="padding-eft" v-for="(item, index) in listFrom" :key="index" @tap="search4(item)">
					<view class="">
						{{item.store_name}}
					</view>
				</view>
			</view>
		</u-popup>

		<u-popup v-model="redactShow3" mode="top" width="100%" border-radius="40">

			<!-- 公共头部 -->
			<header-box :title="title"></header-box>
			<view style="padding: 13rpx 23rpx;
				font-family: PingFang SC;
				background-color: #EBEBF0;
				color: #333333; width: 140rpx;
				font-size: 24rpx; margin: 30rpx;
				text-align: center;">供应商</view>
			<view class="text-fw" style="margin-left: 30rpx; margin-bottom: 30rpx; ">
				供应商
			</view>
			<view class="cen">
				<view class="padding-eft" v-for="(item, index) in danwFromlIstanbul" :key="index" @tap="search5(item)">
					<view class="">
						{{item.supplier_name}}
					</view>
				</view>
			</view>
		</u-popup>





		<u-popup v-model="popupShow" mode="center" width="70%" height="280rpx" border-radius="10">
			<view class="input-text">
				商品分类
			</view>
			<view class="input-val">
				<input type="text" value="" style="background-color: #F0F0F0; text-align: center;" placeholder="请输入商品类目" />
			</view>
			<view class="text-select">
				<view class="" @click="popupShow = false">
					取消
				</view>
				<view class="">
					确定
				</view>
			</view>
		</u-popup>

		<u-calendar v-model="show" :mode="mode" @change="change"></u-calendar>
		<u-calendar v-model="show1" :mode="mode" @change="change1"></u-calendar>


	</view>
</template>

<script>
	import headerBox from '../../components/header/header.vue'

	export default {
		components: {
			headerBox
		},
		data() {
			return {
				title: '入库单',
				textList: [],
				addUrl: '',
				redactShow: false,
				list: [{
					name: '编辑',
					show: true
				}, {
					name: '删除',
					show: true
				}, {
					name: '取消',
					show: false
				}],
				tabText: 0,
				popupShow: false,
				redactShow1: false,
				redactShow2: false,
				redactShow3: false,
				stock: '1',
				total: '',
				page: 1, // 页面
				rows: 10, // 每页条数
				statckTime: '',
				endTime: '',
				show1: false,
				show: false,
				mode: 'date',
				valText: '',
				strackName: '',
				supplierName: '',
				supplierId: '',
				listFrom: [],
				store_id: this.store_id,
				danwFromlIstanbul: [],
			}
		},
		onLoad() {
			this.search2()
			this.getList()
			this.danweiList()
		},
		onShow() {
			uni.removeStorageSync('navigatorProp')
			uni.removeStorageSync('list')
			uni.removeStorageSync('goodsList')
		},
		onReachBottom() {
			console.log('触底了')
			if (this.page * this.rows >= this.total) return this.$tools.msg('没有更多了！')
			this.page++
			this.getList()
		},
		methods: {

			goback(id, ) {
				uni.navigateTo({
					url: '/pages/putStock/shoppingInfo?infoId=' + id + '&stock=' + 1
				})
			},


			search() {
				this.page = 1
				this.strackName = ''
				this.supplierName = ''
				this.supplierId = ''
				this.store_id = ''
				this.textList = []
				this.getList()
			},

			async search1() {
				const {
					data: res
				} = await this.$u.post("api/jinxiao.Enter/index", {
					keyword: this.valText,
				});
				this.textList = res.list
				this.redactShow1 = false
			},

			async search2() {
				const res = await this.$u.post("api/Invoic/get_store");
				this.listFrom = res.data
				this.redactShow = false
			},

			async search4(item) {
				this.page = 1
				this.strackName = ''
				this.supplierName = ''
				this.supplierId = ''
				this.store_id = ''
				this.textList = []
				this.store_id = item.id
				this.strackName = item.store_name
				this.getList()
				this.redactShow2 = false
			},

			async search5(item) {
				this.page = 1
				this.strackName = ''
				this.supplierName = ''
				this.supplierId = ''
				this.store_id = ''
				this.supplierName = item.supplier_name
				this.textList = []
				this.supplierId = item.id
				this.getList()
				this.redactShow3 = false
			},

			async danweiList(id) {
				const {
					data: res
				} = await this.$u.post("api/Invoic/supplier_find", {});
				this.redactShow3 = false
				this.danwFromlIstanbul = res
				console.log('res', this.danwFromlIstanbul)
			},

			async getList(id) {
				const res = await this.$u.post("api/Invoic/buy_order_find", {
					page: this.page,
					pagesize: this.rows,
					supplier_id: this.supplierId ? this.supplierId : '',
					store_id: this.store_id ? this.store_id : '',
				});
				this.textList = [...this.textList, ...res.data]
				// this.total = res.total
				console.log('进入id', res)
			},

			elect(item, index) {
				console.log(index)
				this.tabText = index
				this.redactShow = item.show
				if (index == 0) {
					uni.navigateTo({
						url: '/pages/shopping/compile'
					})
					// 跳转到编辑页面
					// this.redactShow = true
				} else if (index == 1) {
					// 调用删除事件
				}
			},

			change(e) {
				this.statckTime = e.result
				console.log(e.result);
			},

			change1(e) {
				this.endTime = e.result
				console.log(e);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.conter {
		width: 100%;
		height: 100%;
		font-size: 24rpx;
		background-color: #EEEEEE;
		position: relative;

		image {
			width: 100%;
			height: 100%;
		}

		.text-tab {
			width: 100%;
			padding: 30rpx;
			padding-bottom: 0;
			// background-color: #FFFFFF;

			.box-width {
				color: #333333;
				width: 90% !important;
				margin-bottom: 30rpx;

				view {
					padding: 13rpx 23rpx;
					background: #FFFFFF;
					border-radius: 6rpx;
				}
			}

			.box {
				width: 100%;
				color: #666666;
				padding: 30rpx 30rpx 0;
				background-color: #FFFFFF;
				border-radius: 10rpx;
				margin-bottom: 30rpx;

				.box-title {
					width: 100%;
					display: flex;
					justify-content: space-between;
					align-items: center;
					height: 60rpx;
					font-size: 28rpx;
					font-weight: bold;
					color: #000000;
					font-family: PingFang SC;
					line-height: 60rpx;
				}

				.box-data {
					height: 60rpx;
					line-height: 60rpx;
				}

				.bot-bor {
					height: 88rpx;
					line-height: 88rpx;
				}
			}

			.box-width {
				width: 90%;
			}

			.marige-bor {
				width: 100%;
				margin: 0 auto;
				color: #333333;
				display: flex;
				font-size: 28rpx;
				align-items: center;
				background-color: #FFFFFF;
				border-top: 1rpx solid #F0F0F0;
				justify-content: space-between;

				.diso-flex {
					width: 90%;
					height: 80rpx;
					display: flex;
					align-items: center;
					justify-content: space-around;
				}

				.conter-image {
					width: 22rpx;
					height: 36rpx;
					font-weight: 700;
					color: #999;
				}
			}

			.marige-bor:last-child {
				border-bottom: 0;
			}
		}

		// 加号
		.add {
			position: fixed;
			bottom: 200rpx;
			right: 40rpx;
			width: 100rpx;
			height: 100rpx;
			text-align: center;
			line-height: 100rpx;
			border-radius: 50%;
			font-size: 100rpx;
			color: #FFFFFF;
			opacity: 0.9;
		}

		.total {
			width: 100%;
			position: absolute;
			bottom: 0;
			left: 0;
			height: 100rpx;
			padding: 0 60rpx 0 30rpx;
			background-color: #FFFFFF;
		}

	}

	.padd-text {
		width: 80%;
		height: 106rpx;
		line-height: 106rpx;
		text-align: center;
		font-size: 28rpx;
		color: #333;
		border-bottom: 1rpx solid #EEEEEE;
		margin: 0 auto;
	}

	.color-text {
		color: #7278EC;
	}

	.none-color {
		color: #000;
	}

	.input-text {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		margin-top: 10rpx;
	}

	.input-val {
		width: 80%;
		height: 78rpx;
		margin: 0 auto;
	}

	.text-select {
		width: 90%;
		margin: 0 auto;
		border-top: 1rpx solid #F0F0F0;
		display: flex;
		// padding-top: 20rpx;
		justify-content: space-around;

		view {
			width: 50%;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			border-right: 1rpx solid #F0F0F0;
		}

		view:last-child {
			border-right: 0;
		}
	}

	.flex-box1 {
		display: flex;
		margin: 0 30rpx;
		justify-content: space-around;
	}


	.flex-box2 {
		margin: 0 30rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;

		view {
			line-height: 50rpx;
		}
	}

	.box1 {
		display: flex;
		align-items: center;
		justify-content: space-around;
		margin: 0 30rpx;

		.box-bgc {
			width: 330rpx;
			height: 60rpx;
			text-align: center;
			line-height: 60rpx;
			border-radius: 6rpx;
			background-color: #F2F3F7;
		}
	}

	.search-box {
		width: 90%;
		height: 70rpx;
		line-height: 70rpx;
		font-size: 28rpx;
		border-radius: 35rpx;
		text-align: center;
		margin: 0 auto 50rpx;
	}

	.cen {

		.padding-eft {
			width: 90%;
			height: 76rpx;
			margin: 0 auto;
			line-height: 76rpx;
			padding-left: 0;
			border-bottom: 1rpx solid #F5F5F5;

			view {
				width: 100%;
			}
		}

		.padding-eft:last-child {
			border-bottom: 0;
		}
	}
</style>
